/**
 * @file     tribonacci.js
 * @brief    [1137. 第 N 个泰波那契数](https://leetcode.cn/problems/n-th-tribonacci-number/)
 * @author   Zhu
 * @date     2024-12-03 15:09
 */

/**
 * @param {number} n
 * @return {number}
 */
var tribonacci = function (n) {
    const table = [0, 1, 1];
    let i = 3;
    while (i <= n) {
        table[i] = table[i - 1] + table[i - 2] + table[i - 3];
        i++;
    }

    return table[n];
};
